# Contributor: Gennady Feldman <gena01@gmail.com>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=consul-template
pkgver=0.25.1
pkgrel=0
pkgdesc="Generic template rendering and notifications with Consul"
url="https://www.consul.io/"
arch="all !mips !mips64"
license="MPL-2.0"
makedepends="go"
options="!check"
subpackages="$pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/hashicorp/consul-template/archive/v$pkgver.tar.gz
	consul-template.hcl
	consul-template.initd
	"

build() {
	CGO_ENABLED="0" go build -a -v -o bin/$pkgname \
		-ldflags "-s -w
			-X github.com/hashicorp/$pkgname/version.Name=$pkgname \
			-X github.com/hashicorp/$pkgname/version.GitCommit=$pkgver"
}

package() {
	# Main binary
	install -m750 -D bin/$pkgname "$pkgdir"/usr/sbin/$pkgname
	install -Dm644 "$srcdir"/consul-template.hcl "$pkgdir"/etc/"$pkgname"/"$pkgname".hcl
	install -Dm755 "$srcdir"/consul-template.initd "$pkgdir"/etc/init.d/"$pkgname"
}

cleanup_srcdir() {
	[ -d src ] && chmod -R +w src
	default_cleanup_srcdir
}

sha512sums="ac02d6c26daadda62aff9b908836a6ac342ebebb9429c7a75306c4a76a2ba6bc6ab97f26e17ebfa64c171622068f89d006d48ccd7bfa28a71b43245357cbf524  consul-template-0.25.1.tar.gz
bfb5c7eed53cfe45d9e03eeb68eb454d2f47a47402a99b008895c261389160d611ab72903cdfb98e99a88749e0fd00733a9fad70b9def9af35657cba12987ea9  consul-template.hcl
15a5edc20c3239743c58ca485dc51e2851a072b9b2424980854aa4842ac423d65041584a6572c81eab328ed68a41094b7a6771dd94c33155db741b27259f5ff6  consul-template.initd"
